package com.itheimai02;

public class Student implements Comparable<Student>{
    private String name;
    private int age;
    private int sum;

    public Student() {
    }

    public Student(String name, int age, int sum) {
        this.name = name;
        this.age = age;
        this.sum = sum;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getSum() {
        return sum;
    }

    public void setSum(int sum) {
        this.sum = sum;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", sum=" + sum +
                '}';
    }

    @Override
    public int compareTo(Student o) {
       int num = o.getSum()-this.getSum();
       num=num==0? this.getAge()-o.getAge():num;
       num=num==0? this.getName().compareTo(o.getName()):num;
       return num;
    }
}
